<template>
    <rx-dialog @handOk="handOk" @cancel="cancel">
        <rx-layout style="width: calc(100% - 2px)">
        <div slot="header">
            <div class="table-page-search-wrapper" border="false">
                <a-form layout="inline">
                    <a-row :gutter="24">
                        <a-col :span="8">
                            <a-form-item :label="i18n('form.policyName','策略名称')">
                                <a-input :placeholder="i18n('form.policyName','策略名称','input')" v-model="queryParam.Q_NAME__S_LK"/>
                            </a-form-item>
                        </a-col>
                        <a-col :span="8">
                            <span class="table-page-search-submitButtons">
                                <a-button @click="$refs.table.loadData()" icon="search" type="primary">{{$ti18('rxList.searchBtn','查询')}}</a-button>
                                <a-button @click="resetSearchList" style="margin-left: 4px">{{$ti18('rxList.resetBtn','重置')}}</a-button>
                            </span>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
        </div>
        <div slot="center" style="margin: 10px">
                <rx-grid
                    ref="table"
                    :bordered="false"
                    :allowRowSelect="true"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-form/form/core/formQueryStrategy/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    rowKey="id"
                    @selectChange="onSelectChange"
                >
                </rx-grid>
        </div>
    </rx-layout>
    </rx-dialog>
</template>

<script>
import FormQueryStrategyApi from '@/api/form/core/formQueryStrategy'
import FormBoListApi from "@/api/form/core/formBoList"
import FormQueryStrategyEdit from './FormQueryStrategyEdit'
import {BaseList, RxGrid,Util} from "@lowcode/jpaas-common-lib";
import DialogBox from "../../../../assets/js/DialogBox";
export default {
    name: 'FormQueryStartegyDialog',
    mixins: [BaseList],
    props: {
        layerid: {
            type: String,
            default: ""
        },
        destroy: {
            type: Function
        },
        listId:{
            type: String,
            default: ""
        }
    },
    components: {
        RxGrid
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index','序号'),
                    type: 'indexColumn',
                    width: 100,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.i18n('form.policyName','策略名称'), dataIndex: 'name', width: 100},
            ],
            component: FormQueryStrategyEdit,
            comment: this.i18n('list.comment','查询策略表'),
            widthHeight: ['800px', '600px'],
        }
    },
    created() {
        this.queryParam['Q_LIST_ID__S_EQ'] = this.listId;
        this.needFilterAppId();
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"FormQueryStrategy",key);
        },
        resetSearchList () {
            this.$nextTick(()=>{
                this.queryParam={Q_LIST_ID__S_EQ:this.listId};
                let appId=this.curApp.appId;
                if(appId){
                    this.queryParam.Q_APP_ID__S_EQ=appId;
                }
                this.$nextTick(()=>{
                    this.$refs[this.table].loadData();
                })
            })
        },
        getListByParams(parameter) {
            return FormQueryStrategyApi.query(parameter)
        },
        handOk(vm) {
            var rows = this.selectedRows;
            if (rows.length == 0) {
                vm.loading = false;
                this.$message.warning(this.$ti18('rxMsa.masWarn.selectOneRecord','请选择一行记录!'));
                return;
            }
            Util.closeWindow(this, "ok", this.selectedRows);
        },
        cancel() {
            Util.closeWindow(this, "cancel");
        },
    }
}
</script>
<style scoped>

</style>

